#include <stdio.h>
#include<malloc.h>
#define  _CRT_SECURE_NO_WARNINGS
struct TreeNode {
     char val;
     struct TreeNode *left;
     struct TreeNode *right;
 };
struct TreeNode * perorder(const char *s,int *pi)
{
    if(s[*pi]=='#')
    {
        (*pi)++;
        return NULL;
    }
    struct TreeNode *tmp=(struct TreeNode*)malloc(sizeof(struct TreeNode));
    tmp->val=s[(*pi)++];
    tmp->left=perorder(s,pi);
    tmp->right=perorder(s,pi);
    return tmp;
}
void inorder(struct TreeNode*tmp)
{
    if(tmp==NULL)return;
    inorder(tmp->left);
    printf("%c ",tmp->val);
    inorder(tmp->right);
}
int main() {
    char s[101];
    scanf("%s",s);
    int i=0;
    struct TreeNode* tmp;
    tmp=perorder(s,&i);
    inorder(tmp);
    return 0;
}